<?php 
defined('_JEXEC') or die;
JLoader::register("PResumesHelper", OC_App::getAppPath('resumes') . "/lib/helper.php");

// disable core styles to avoid bs conflict 
OC_Util::$core_styles = array();
if (isDevMode()) {
   // Style
   OCP\Util::addStyle('calendar', 'calendar');
   OCP\Util::addStyle('calendar', 'calendar.common');
   OCP\Util::addStyle('themes/jobs/core/js/jquery/jquery-timepicker', 'jquery.timepicker');
   // Js
   OCP\Util::addScript('calendar', 'calendar.list');
   OCP\Util::addScript('calendar', 'calendar.common');
   OCP\Util::addscript('themes/jobs/core/js/jquery/jquery-timepicker', 'jquery.timepicker');
} else {
   OCP\Util::addStyle('static', 'calendar.list');
   OCP\Util::addScript('static', 'apps/calendar.list.min');
}
OCP\App::setActiveNavigationEntry('calendar_index');
$iknow_seeall = JRequest::getString('iknow_seeall', null, 'cookie');
$user = PFactory::getUser();
?>

<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('calendar/js', 'l10n.php'));?>"></script>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('calendar/js', 'calendar.php'));?>"></script>
<div class="hr_inner_navigate clearfix" id="hr_inner_navigate">
   <ul class="clearfix">
      <li><a href="<?=OC_Helper::linkToRoute("calendar_home")?>">日历模式</a></li>
      <li class="cur_li"><a href="<?=OC_Helper::linkToRoute("calendar_list")?>">列表模式</a></li>
   </ul>
      
   <div class="positionselect medium pull-left">
      <span>职位：</span>
      <div id="joblinks" class="comselectmenubox dropdown">
          <?php 
             $jobid = JRequest::getInt('jobid', 0);
             $selectedjob = PResumesHelper::getJob($jobid);
          ?>
         <span data-target="#" data-toggle="dropdown" class="needp_relative dropdown-toggle"><b><?=(empty($selectedjob) ? '全部' : $selectedjob->job_title) ?></b> <i></i></span>
         <div class="needp_absolute dropdown-menu">
            <?php 
               list($href, $selected) = PResumesHelper::getSearchItemHref($_['searchUrl'], 'jobid', 'all');
            ?>
            <a href="<?=$href?>" <?=($selected ? 'class="cur_a"'  : '')?>>全部</a>
            <?php
            foreach ($_['joblists'] as $key=>$joblists){ 
               list($href, $selected) = PResumesHelper::getSearchItemHref($_['searchUrl'], 'jobid', $joblists['id']);?>
            <a href="<?=$href ?>" <?=($selected ? 'class="cur_a"'  : '')?>><?=$joblists['job_title'] ?></a>
            <?php if($key==9){ ?>
            <a class="last_lookmore" href="javascript:;">查看更多</a>
            <?php break;}} ?>
         </div>
      </div>
   </div>
      
   <div class="separated_line pull-left">|</div>
   <div class="sequence_time medium pull-left" id="sequence_time">
      <a class="highlight_arrow" href="javascript:;" data-orderdir="<?php echo empty($_['listorders'])?'ASC':$_['listorders']['orderdir']; ?>" data-orderby="startdate">按时间排序<?php if($_['listorders']['orderdir']=='DESC'){ echo '<i class="timedown"></i>'; }else{echo '<i class="timeup"></i>' ;}?></a>
   </div>
   
   <?php if(0): ?>
   <div class="separated_line pull-left">|</div>
   
   <div class="highsearch pull-left medium" id="advancedSearch" style="margin:11px 0 0 15px;">
       <a href="javascript:;">高级筛选<i></i></a>
    </div>
   <?php endif; ?>
   
   <div class="separated_line pull-left">|</div>
   <div class="selectearly medium pull-left" id="selectearly">
      <label class="checkbox">
         <input type="checkbox" value="<?=$_['show_prev'] ?>" id="selectall" <?php echo $_['show_prev'] == 1 ? 'checked="checked"' : '';?>>
         显示今日以前
      </label>
      
      <?php if(empty($iknow_seeall)): ?>
      <div class="showearly_puptip iknowtext"><span>去掉勾选，只显示今日及以后的面试安排。</span> <a href="javascript:;" data-cookie="7" data-cookiename="iknow_seeall" class="iknow">我知道了</a></div>
      <?php endif; ?>
   </div>
</div>

<div id="resumesearch_wrap" data="{'searchurl': '<?=$_['searchUrl']?>', 'jobid': '<?=JRequest::getInt('jobid', 0)?>'}" class="resumesearch_wrap"  style="display: none;"></div>

<?php if(0): ?>
<form id="checkboxsearchform" action="<?php echo OC_Helper::linkToRoute("calendar_search"); ?>" method="get" name="checkboxsearchform">
<div class="highsearch_wrap" id="checkboxsearch" style="display:none;">
   <div class="highsearch_eachbox medium clearfix">
      <label class="">面试反馈：</label>
      <ul>
         <li class="cur_selected"><a href="#">全部</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewfeedback[]" value="1"/><a href="#">已完成</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewfeedback[]" value="0"/><a href="#">未完成</a></li>
      </ul>
   </div>
   <div class="highsearch_eachbox medium clearfix">
      <label class="">面试结果：</label>
      <ul>
         <li class="cur_selected"><a href="#">全部</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult2[]" value="7"/><a href="#">尚未开始</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult2[]" value="6"/><a href="#">正在面试</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult[]" value="1"/><a href="#">面试合格</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult[]" value="2"/><a href="#">面试不合格</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult[]" value="3"/><a href="#">复试</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult[]" value="4"/><a href="#">缺席</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult2[]" value="8"/><a href="#">已过期</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="interviewresult[]" value="5"/><a href="#">已取消</a></li>
      </ul>
   </div>
   <div class="highsearch_eachbox medium clearfix">
      <label class="">offer：</label>
      <ul>
         <li class="cur_selected"><a href="#">全部</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="offer[]" value="0"/><a href="#">已发</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="offer[]" value="3"/><a href="#">未发</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="offer[]" value="1"/><a href="#">接受offer</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="offer[]" value="2"/><a href="#">拒绝offer</a></li>
      </ul>
   </div>
   <div class="highsearch_eachbox medium clearfix">
      <label class="">入职：</label>
      <ul>
         <li class="cur_selected"><a href="#">全部</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="entry[]" value="1"/><a href="#">已入职</a></li>
         <li class="line">|</li>
         <li><input type="checkbox" name="entry[]" value="0"/><a href="#">已过期</a></li>
      </ul>
   </div>
   <div class="highsearch_eachbox medium clearfix">
      <label class=""></label>
      <div class="selected_bluebtn" id="selectsearch"><input class="ppp_bluebtn" type="submit" name="submit" value="筛选"></div>
   </div>
   <div class="click_slideup"></div>
</div>
</form>
<?php endif; ?>

<div class="hr_manegeinterview_set" style="padding-top:40px;">
   <div class="interviewlist_wrap" style="padding-bottom:24px;">
     <?php if(!empty($_['showlist'])){ ?>  
     <?php foreach ($_['showlist'] as $key=>$lists): ?>
      <div class="interviewlist_eachbox <?php if($key%2!=0){echo 'interviewlist_eachbox_bg';} ?>" data-jobid="<?=$lists->jobid?>">
         <div class="invite_positionname"><a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$lists->jobid, 'job_title'=>$lists->job_title));?>" target="_blank"><?=$lists->job_title ?></a></div>
      
         <div class="invite_jobname"><a href="<?php echo $_['viewURL'].$lists->jobseekerid.'&name='.JFilterOutput::stringURLUnicodeSlug($lists->jobseekername); ?>" target="_blank"><b><?=$lists->jobseekername ?></b></a>
         <em style="color:#d2871d;"><b><?php if($lists->round-1>0){ ?>（第<?php echo ($lists->round)?>轮面试）<?php } ?></b></em>
         </div>
      
         <div class="invite_progress" id="invite<?=$lists->objectid ?>">
            <b class="black">面试进度：</b>
            <span id="interviewlists"><a href="javascript:;" data="{jobseekid:<?=$lists->jobseekerid ?>,objectid:<?=$lists->objectid ?>,jobid:<?=$lists->jobid ?>}"><?php echo JHtml::_('date',$lists->startdate, 'Y-m-d');  ?>&nbsp;&nbsp;<?php echo JHtml::_('date',$lists->startdate, 'H:i'); ?></a></span>
            <span class="rightpoint"></span>
            <span id="interviewfeedback"><a href="javascript:;" data="{jobseekid:<?=$lists->jobseekerid ?>,jobid:<?=$lists->jobid ?>}">面试反馈(<?=$lists->totalfeedbacks ?>/<?=$lists->totalinterviewers ?>)&nbsp;
            <?php if($lists->totalfeedbacks == $lists->totalinterviewers && !empty($lists->totalfeedbacks)): ?>
            <i class='finish ok'></i>
            <?php else: ?>
            <i class='finish notok'></i>
            <?php endif; ?>
            </a></span>
            <span class="rightpoint"></span>
            <span><em style="color:#333333;">面试结果:</em>
               <?php if($lists->haspermission == 1): ?>
               <div class="dropdown inviteresume_dropdown">
                  <a href="javascript:;" class="ppp_whitebtn dropdown-toggle" data-toggle="dropdown" data-target="#" style="width:90px;">
                  <b id="resultlists<?=$lists->objectid ?>"> <?php echo empty($lists->result)?'--':$lists->result; ?> </b>
                  <i class="blue_triangle"></i>
                  </a>
                  <div class="dropdown-menu" id="dropdownmenu" style="width:90px;">
                  <a href="javascript:;" data="{'resultid':<?=PCalendarHelper::INTERVIEW_RESULT_HIRE ?>,'jobid':'<?=$lists->jobid ?>','objectid':'<?=$lists->objectid ?>','statusid':<?=PCalendarHelper::JOBSEEKER_STATUS_HIRE ?>,'jobseekerid':'<?=$lists->jobseekerid ?>','offerstatus':<?=$lists->offerstat ?>}">面试合格</a>
                  <a href="javascript:;" data="{'resultid':<?=PCalendarHelper::INTERVIEW_RESULT_NOTHIRE ?>,'jobid':'<?=$lists->jobid ?>','objectid':'<?=$lists->objectid ?>','statusid':<?=PCalendarHelper::JOBSEEKER_STATUS_NOTHIRE ?>,'jobseekerid':'<?=$lists->jobseekerid ?>','offerstatus':<?=$lists->offerstat ?>,'declinestatus':<?=$lists->interview_result ?>}">面试不合格</a>
                  <a href="javascript:;" data="{'resultid':<?=PCalendarHelper::INTERVIEW_RESULT_RETEST ?>,'jobid':'<?=$lists->jobid ?>','objectid':'<?=$lists->objectid ?>','statusid':<?=PCalendarHelper::JOBSEEKER_STATUS_RETEST ?>,'jobseekerid':'<?=$lists->jobseekerid ?>','jobseekername':'<?=addslashes($lists->jobseekername) ?>','jobtitle':'<?=addslashes($lists->job_title) ?>','round':'<?=$lists->round ?>','validemail':'<?=isFakeEmail($lists->email) ? 0 : 1 ?>'}">复试</a>
                  <a href="javascript:;" data="{'resultid':<?=PCalendarHelper::INTERVIEW_RESULT_ABSENT ?>,'jobid':'<?=$lists->jobid ?>','objectid':'<?=$lists->objectid ?>','statusid':<?=PCalendarHelper::JOBSEEKER_STATUS_ABSENT ?>,'jobseekerid':'<?=$lists->jobseekerid ?>','offerstatus':<?=$lists->offerstat ?>}">缺席</a>
                  <a href="javascript:;" data="{'resultid':<?=PCalendarHelper::INTERVIEW_RESULT_CANCEL ?>,'jobid':'<?=$lists->jobid ?>','objectid':'<?=$lists->objectid ?>','statusid':<?=PCalendarHelper::JOBSEEKER_STATUS_CANCEL ?>,'jobseekerid':'<?=$lists->jobseekerid ?>','offerstatus':<?=$lists->offerstat ?>,'canceled':<?=$lists->canceled ?>}" data-showtext='已取消'>取消</a>
                  </div>
               </div>
               <?php else: ?>
                  <b id="resultlists<?=$lists->objectid ?>" <?php echo empty($lists->result)?'title="面试结果未定"':''; ?>> <?php echo empty($lists->result)?'--':$lists->result; ?> </b>
               <?php endif; ?>
            </span>
            <?php 
               $style1 = 'none';
               $style2 = 'none';
               if($lists->result == '面试合格'){
                  $style1 = 'inline-block';
               }
               if($lists->result == '面试不合格'){
                  $style2 = 'inline-block';
               }
            ?>
            <span style="display:<?=$style1 ?>;" class="rightpoint"></span>
            <?php if($lists->offerstat > 0){ ?>
            <span style="display:<?=$style1 ?>;">
            <?php if($lists->haspermission == 1): ?>


            <a href="javascript:;" id="sendoffer" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,jobid:<?=$lists->jobid ?>,eventid:<?=$lists->offereventid ?>,validemail:<?=(isFakeEmail($lists->email) ? '0':'1')?>}">发offer&nbsp;<i class='finish ok'></i></a>
            <?php else: ?>
            发offer&nbsp;<i class='finish ok'></i>
            <?php endif; ?>
            </span>           
            <span style="display:<?=$style1 ?>;" class="rightpoint"></span>
            <span style="display:<?=$style1 ?>;">
               <?php if($lists->haspermission == 1): ?>
               <div class="dropdown inviteresume_dropdown">
                  <a href="javascript:;" class="ppp_whitebtn dropdown-toggle" data-toggle="dropdown" data-target="#"><b id="offerresulttext<?=$lists->objectid ?>"><?php if(empty($lists->offerresult)){echo'--';}elseif($lists->offerresult == '入职'){echo '接受offer';}else{echo $lists->offerresult; } ?></b> <i class="blue_triangle"></i></a>
                  <div class="dropdown-menu" id="offerstat">
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,offerstat:<?=PCalendarHelper::OFFER_FEEDBACKSTATUS_REJECTED ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_REJECTED ?>,jobid:<?=$lists->jobid ?>}">拒绝offer</a>
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,offerstat:<?=PCalendarHelper::OFFER_FEEDBACKSTATUS_ACCEPTED ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_ACCEPTED ?>,jobid:<?=$lists->jobid ?>}">接受offer</a>
                  </div>
               </div>
               <?php else: ?>
                  <b id="offerresulttext<?=$lists->objectid ?>" <?php echo empty($lists->offerresult)?'title="offer结果未定"':'';?>><?php if(empty($lists->offerresult)){echo'--';}elseif($lists->offerresult == '入职'){echo '接受offer';}else{echo $lists->offerresult; } ?></b>
               <?php endif; ?>
            </span>
            <?php $style3 = 'none';
                  if($lists->result == '面试合格' && ($lists->offerresult == '接受offer' || $lists->offerresult == '入职')){
                     $style3 = 'inline-block';
                  }
            ?>
            <span style="display:<?=$style3 ?>;" class="rightpoint"></span>
            <span style="display:<?=$style3 ?>;">
               <?php if($lists->haspermission == 1): ?>
               <div class="dropdown inviteresume_dropdown">
                  <a href="javascript:;" class="ppp_whitebtn dropdown-toggle" data-toggle="dropdown" data-target="#"><b id="entryresulttext<?=$lists->objectid ?>"><?php if($lists->offerresult == '入职'){ echo '试用期'; }elseif(empty($lists->entryresult)){echo'待入职';}else{echo $lists->entryresult; } ?></b> <i class="blue_triangle"></i></a>
                  <div class="dropdown-menu" id="entrystat">
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,entrystat:<?=PCalendarHelper::ENTRY_FEEDBACKSTATUS_NOENTRY ?>,jobid:<?=$lists->jobid ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_NOENTRY ?>}">待入职</a>
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,entrystat:<?=PCalendarHelper::ENTRY_FEEDBACKSTATUS_PROBATION ?>,jobid:<?=$lists->jobid ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_PROBATION ?>}">试用期</a>
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,entrystat:<?=PCalendarHelper::ENTRY_FEEDBACKSTATUS_POSITIVE ?>,jobid:<?=$lists->jobid ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_POSITIVE ?>}">转正</a>
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,entrystat:<?=PCalendarHelper::ENTRY_FEEDBACKSTATUS_DISMISS ?>,jobid:<?=$lists->jobid ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_DISMISS ?>}">辞退</a>
                     <a href="javascript:;" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,entrystat:<?=PCalendarHelper::ENTRY_FEEDBACKSTATUS_VOLUNTARY_TURNOVER ?>,jobid:<?=$lists->jobid ?>,statusid:<?=PCalendarHelper::JOBSEEKER_STATUS_VOLUNTARY_TURNOVER ?>}">主动离职</a>
                  </div>
               </div>
               <?php else: ?>
               <b id="entryresulttext<?=$lists->objectid ?>"><?php if($lists->offerresult == '入职'){ echo '试用期'; }elseif(empty($lists->entryresult)){echo'待入职';}else{echo $lists->entryresult; } ?></b>
               <?php endif; ?>
            </span>
            <?php }else{ ?>
            <span style="display:<?=$style1 ?>;">
            <?php if($lists->haspermission == 1): ?>
            <a href="javascript:;" id="sendoffer" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,jobid:<?=$lists->jobid ?>,eventid:'',validemail:<?=(isFakeEmail($lists->email) ? '0':'1')?>}">发offer&nbsp;<i class='finish notok'></i></a>
            <?php else: ?>
                              发offer&nbsp;<i class='finish notok'></i>
            <?php endif; ?>
            </span>
            <?php } ?>

            <span style="display:<?=$style2 ?>;" class="rightpoint"></span>
            <span style="display:<?=$style2 ?>;" id="span<?=$lists->jobseekerid ?>">
            <?php if($lists->interview_result == 1): ?>
            <a href="javascript:;" id="senddecline" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,jobid:<?=$lists->jobid ?>}">通知不录用&nbsp;<i class='finish ok'></i></a>
            <?php else: ?>
            <?php if($lists->haspermission == 1): ?>
            <a href="javascript:;" id="senddecline" data="{objectid:<?=$lists->objectid ?>,jobseekid:<?=$lists->jobseekerid ?>,jobid:<?=$lists->jobid ?>}">通知不录用&nbsp;<i class='finish notok'></i></a>
            <?php else: ?>
                              通知不录用&nbsp;<i class='finish notok'></i>
            <?php endif; ?>
            <?php endif; ?>
            </span>

         </div>
      </div>
      <div class="modal clearinterview popup" data-pagetype="2" style="position:absolute; display:none;" id="cancel_showdialog">
      </div>
      <?php endforeach; ?>
      <?php }else{ 
               echo '<div class="large yahei nointerviewdata">没有找到符合条件的日程</div>';
            } ?>
   </div>
   <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
</div>

<div style="padding-top:0px;<?php echo ($_['pagination']->pagesTotal > 1) ? '' : 'display:none;'?>">
   <?php echo $_['pagination']->getListFooter(); ?>
</div>

<div class="modal hide fade clearinterview" style="position:absolute;" id="notify_showdialog">
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>&nbsp;</h3>
   </div>
   <div class="modal-body" id="">
      <div class="ciw_words" style="padding-left:0px;">您可以在此页或 <a href="<?=OC_Helper::linkToRoute("calendar_home")?>">面试管理</a> 中查看面试进度。</div>
   </div>
</div>
<input name="icomp_name" value="<?php echo $user->name; ?>" type="hidden" id="icomp_name">

<!--复试DIALOG-->
<div class="modal changeinterview_dialog popup" id="preview_holder" style="display:none; position:absolute"><!-- 这里的定位开发到时候用position的JS 定位，把style删掉 --></div>
<!--面试反馈的dialog-->
<div id="feedback_dialog" class="popup" style="display:none; position:absolute;"></div>
<!--发offer的dialog-->
<div class="modal hide fade interviewtime_dialog" id="sendofferdialog" style="display:none; position:absolute;"></div>
<!--不录用通知的dialog-->
<div class="modal hide fade interviewtime_dialog" id="senddeclinedialog" style="display:none; position:absolute"></div>
<!--修改安排面试的dialog-->
<div class="modal hide fade interviewtime_dialog" id="modal_holder" style="position:absolute;"></div>
<!--面试结果的dialog 已经面试上了-->
<div class="modal interresult_dialog popup" id="interviewsuccess" style="display:none; position:absolute"></div>
<!--面试结果的dialog 面试失败了-->
<div class="modal hide fade interresult_dialog" id="interviewfailed" style="position:absolute;"></div>
<!--新建面试安排的dialog-->
<div id="event_modal" class="modal hide fade interviewtime_dialog" style="position:absolute;"></div>
<!--编辑offer内容的dialog-->
<div id="modal_holder" class="modal hide interviewtime_dialog" style="position:absolute;"></div>
